package cn.iocoder.devlop.module.annual.report.socsecinfo.controller.app;

import cn.iocoder.devlop.framework.common.pojo.CommonResult;
import cn.iocoder.devlop.module.annual.report.socsecinfo.controller.vo.SocsecinfoOverwriteVO;
import cn.iocoder.devlop.module.annual.report.socsecinfo.controller.vo.SocsecinfoRespVO;
import cn.iocoder.devlop.module.annual.report.socsecinfo.convert.SocsecinfoConvert;
import cn.iocoder.devlop.module.annual.report.socsecinfo.dal.dataobject.SocsecinfoDO;
import cn.iocoder.devlop.module.annual.report.socsecinfo.service.SocsecinfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.devlop.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 社保信息")
@RestController
@RequestMapping("/annual/report/socsecinfo")
@Validated
public class AppSocsecinfoController {

    @Resource
    private SocsecinfoService socsecinfoService;

    @GetMapping("/list")
    @Operation(summary = "获得年报股权变更信息列表")
    public CommonResult<List<SocsecinfoRespVO>> getSocsecinfoList(@RequestParam("regno") String regno, @RequestParam("ancheyear") String ancheyear) {
        List<SocsecinfoDO> list = socsecinfoService.getSocsecinfoList(regno, ancheyear);
        return success(SocsecinfoConvert.INSTANCE.convertList(list));
    }

    @PutMapping("/overwrite")
    @Operation(summary = "覆盖更新年报股权变更信息列表")
    public CommonResult<Boolean> overwriteSocsecinfo(@Valid @RequestBody SocsecinfoOverwriteVO updateReqVO) {
        socsecinfoService.overwriteSocsecinfo(updateReqVO);
        return success(true);
    }

}
